package com.xkcun.crm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger 配置
 *
 * @author: faze
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {



    @Bean
    public Docket createRestApi() {

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                //.pathMapping("/api")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xkcun.crm.api"))
                .paths(PathSelectors.any())
                .build()
                .groupName("接口");

        return docket;

    }



    /**
     * api 信息配置
     *
     * @param
     * @return springfox.documentation.service.ApiInfo
     * @author faze
     * @date 2019-01-24 14:47
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("提供给crm项目接口 RESTful APIs---")
                .description("测试接口地址：https://")
                .termsOfServiceUrl("http://localhost:9003/discuz-api/swagger-ui.html")
                .contact(new Contact("PUMAN TECH", "", "faze.yan@puman.com"))
                .version("1.0.0")
                .build();
    }

}